#pragma once

#include "IXFont.h"
#include "Util/Include/XString.h"
#include "Logic/Include/XBaseObjImpl.h"

enum eFontFlags
{
    XFont_Bold      = 0x1,
    XFont_Italic    = 0x2,
    XFont_Underline = 0x4,
    XFont_StrikeOut = 0x8,
};

class CXFontImpl : public CXBaseObjImpl<IXFont>
{
    typedef CXBaseObjImpl<IXFont> superclass;
    BEGIN_DEF_SKIN_CLASS(CXFontImpl, superclass, gs_strGuidXSkin)
        IMP_BASIC_INTF(IXFont,        0)
        IMP_BASIC_INTF(IXDrawContextObj, eIntf_NoCreate)
    END_DEF_SKIN_CLASS();

public:
    CXFontImpl();
    virtual ~CXFontImpl();

public:
    // IXDrawContextObj
    virtual void STDMETHODCALLTYPE   SetupCanvas(XCANVAS canvas);
    virtual void STDMETHODCALLTYPE   RestoreCanvas(XCANVAS canvas);
    virtual XHANDLE STDMETHODCALLTYPE get_DrawObj();

public:
    // IXFont
    virtual void STDMETHODCALLTYPE   put_FontSize(IN LONG lFontSize);
    virtual void STDMETHODCALLTYPE   put_Bold(IN BOOL bBold);
    virtual void STDMETHODCALLTYPE   put_Italic(IN BOOL bItalic);
    virtual void STDMETHODCALLTYPE   put_Underline(IN BOOL bUnderline);
    virtual void STDMETHODCALLTYPE   put_StrikeOut(IN BOOL bStrikeOut);
    // virtual void STDMETHODCALLTYPE   put_Charset(IN BYTE byCharset);
    virtual void STDMETHODCALLTYPE   put_FontName(IN LPCTSTR szFontName);

    virtual LONG STDMETHODCALLTYPE   get_FontSize();
    virtual BOOL STDMETHODCALLTYPE   get_Bold();
    virtual BOOL STDMETHODCALLTYPE   get_Italic();
    virtual BOOL STDMETHODCALLTYPE   get_Underline();
    virtual BOOL STDMETHODCALLTYPE   get_StrikeOut();
    // virtual LONG STDMETHODCALLTYPE   get_Charset();
    virtual void STDMETHODCALLTYPE   get_FontName(BSTR* pbstrFontName);

public:
    // IXBaseObj
    virtual void STDMETHODCALLTYPE   OnFinalRelease();

protected:
    void    UpdateFont();
    HFONT   GetFont();
    void    ReleaseFont();

protected:
    LONG    m_lFontSize;
    DWORD   m_dwFontFlags;
    XString m_strFontName;

    HFONT   m_hFont;
    HGDIOBJ m_hOldFont;
};

